package com.amazon.aws.samplecode.travellog.features.users;

import org.springframework.validation.BindingResult;

import com.amazon.aws.samplecode.travellog.entity.User;

/**
 * Before add a user, TravelLog verifies if the username and password fields are
 * filled in correctly.
 * 
 * @UserInterface
 */
public class Login {

	public static void verify(User user, BindingResult result, String password2) {

		// Verify user info submission
		if (user.getUsername().equals("")) {
			result.reject("username", "Username cannot be blank");
		}
		if (user.getPassword().equals("")) {
			result.reject("password", "Password cannot be blank");
		}
		if (!user.getPassword().equals(password2)) {
			result.reject("password", "Passwords do not match");
		}

	}

}
